const express = require('express');
const router = express.Router();
const classController = require('../../controllers/class.controller');
const auth = require('../../middlewares/auth');
const role = require('../../config/roles');
//const validate = require('../../middlewares/validate');
//const classValidation = require('../../validations/class.validation');

// 获取班级信息
router.get(
  '/classes',
  auth(role.TEACHER),
  classController.getClasses
);

// 获取班级实验
router.get(
  '/class/:classId/experiments',
  //'/grades/:classId/experiments',
  auth(role.TEACHER),
  classController.getClassExperiments
);

// 获取班级学生列表
router.get(
  '/class/:classId/students',
  auth(role.TEACHER),
  classController.getClassStudents
);

// 创建班级路由
router.post(
  '/create-class',
  auth(role.TEACHER),
  classController.createClass
);

// 添加班级学生路由
router.post(
  '/class/update-roster',
  auth(role.TEACHER),
  classController.addClassStudent
);

// 添加分配实验路由
router.post(
  '/class/assign-experiment',
  auth(role.TEACHER), // 添加身份验证
  classController.assignExperimentToClass
);

// 更新实验截止日期
router.put(
  '/update-deadline',
  auth(role.TEACHER), // 添加身份验证
  classController.updateExperimentDeadline
);

// 从班级移除实验
router.delete(
  '/remove-experiment/:classId/:experimentId',
  auth(role.TEACHER), // 添加身份验证 
  classController.removeExperimentFromClass
);

// 删除班级学生路由
router.delete(
  '/remove-student/:classId/:studentId',
  auth(role.TEACHER),
  classController.removeClassStudent
);

module.exports = router;